package org.nfIt.exception;

import org.nfIt.entity.Result;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * ClossName:GlobalExceptionHandler
 * Pakage:org.nfIt.exception
 * Description
 *
 * 全局异常消息
 *
 * @Author L
 * @Create 2024/6/4 15:03
 * @Version 2023.1.3
 */

@RestControllerAdvice
public class GlobalExceptionHandler {

    /**
     * 全局异常消息
     * @param e
     * @return
     */
    @ExceptionHandler(Exception.class)
    public Result handleException(Exception e) {
        e.printStackTrace();
        //
        return Result.error(StringUtils.hasText(e.getMessage()) ? e.getMessage() : "操作失败！");
    }




}
